<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title> BMI指数</title>
	</head>
	<body>
		<p>身高(cm)：</p>
		<input id="height" type="text"/>
		<p>体重(kg)：</p>
		<input id="weight" type="text" />
		<br />
		<br />
		<input type="button" value="求BMI" onclick="bmi()"/>	
		<p id="result"></p>
		<script>
			function bmi(){
				var height=document.getElementById('height');
				var weight=document.getElementById('weight');
				var result=document.getElementById('result');
				var h=height.value/100;
				var w=weight.value;
				//bmi值 结果保留2位小数
				var bmi=(w/(h*h)).toFixed(2);
				if(bmi<18.5){
					s+="过轻"
				}else if(bmi<24){
					s+="正常"
				}else if(bmi<27){
					s+="过重"
				}else if(bmi<32){
					s+="肥胖"
				}else{
					s+="非常肥胖"
				}
				result.innerHTML=s;
			}
		</script>
	</body>
</html>
